#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define all(s) (s).begin(),(s).end()
#define endl "\n"
#define eb emplace_back
#define ins insert
#define pq priority_queue

using ll=long long;
using ull=unsigned long long;

constexpr int inf=0x3f3f3f3f;
constexpr ll llinf=0x3f3f3f3f3f3f3f3fll;
constexpr int N=100010;

int n, m;
int a[N], b[N];
int d[31][N];

signed main()
{
    freopen("arena.in", "r", stdin);
    freopen("arena.out", "w", stdout);
    cin.tie(0)->sync_with_stdio(0);
    cin.exceptions(cin.failbit);
    cin>>n>>m;
    for(int i=1; i<=n; i++) cin>>a[i];
    for(int i=1; i<=m; i++) cin>>b[i];
    int k=0; while((1<<k)<n) k++;
    for(int i=1; i<=k; i++)
    {
        for(int j=1; j<=(1<<(k-i)); j++)
            cin>>d[i][j];
    }
    int T; cin>>T;
    while(T--)
    {
        int x_0,x_1,x_2,x_3;
        cin>>x_0>>x_1>>x_2>>x_3;
        
    }
    return 0;
}